

function createUserList(){
    return [
        {
            id:1,
            name:"admin",
            password:"123456",
            token:"admin"
        },
        {
            id:2,
            name:"user",
            password:"123456",
            token:"user"
        }
    ]
}
export default [
    {
        url: '/api/user/login',
        method: 'post',
        response: ({body})=>{
            const {username,password} = body
            const checkUser = createUserList().find(
                (item)=>item.name === username && item.password === password
            )
            if (!checkUser){
                return {code:10001,msg:"账号或密码不正确"}
            }
            const {token}  = checkUser
            return {code: 10000,data:{token}}
        }
    },
    {
        url: '/api/user/info',
        method: 'post',
        response: (request)=>{
            const token = request.headers.token
            const checkUser = createUserList().find((item)=>item.token === token)
            if (!checkUser){
                return {code: 10001,msg:"token错误"}
            }
            return {code:10000,data:{checkUser}}
        }
    }
]